import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/index.vue'

const includPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return includPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: {
            name: 'shouye'
        },
        meta: {
            title: '数据大屏'
        },
        component: Home,
        children: [
            {
                path: '/shouye',
                name: 'shouye',
                meta: {
                    title: '系统首页'
                },
                component: resolve => require(['../views/dpzsSwsy/Index.vue'], resolve)
            },
            {
                path: '/jicha',
                name: 'jicha',
                meta: {
                    title: '稽查主题大屏'
                },
                component: resolve => require(['../views/dpzsSwjc/Index.vue'], resolve)
            },
            {
                path: '/shenbao',
                name: 'shenbao',
                meta: {
                    title: '申报大屏'
                },
                component: resolve => require(['../views/dpzsSwsb/Index.vue'], resolve)
            },
            {
                path: '/dengji',
                name: 'dengji',
                meta: {
                    title: '登记大屏'
                },
                component: resolve => require(['../views/dpzsSwdj/Index.vue'], resolve)
            },
            {
                path: '/diy',
                name: 'diy',
                meta: {
                    title: '定制化'
                },
                component: resolve => require(['../views/dpzsDzh/Index.vue'], resolve)
            },
            {
                path: '/shouru',
                name: 'shouru',
                meta: {
                    title: '税费收入大屏'
                },
                component: resolve => require(['../views/dpzsSwsr/Index.vue'], resolve)
            },
            {
                path: '/gongzhi',
                name: 'gongzhi',
                meta: {
                    title: '数据共治'
                },
                component: resolve => require(['../views/dpzsSjgz/Index.vue'], resolve)
            },
            {
                path: '/fapiao',
                name: 'fapiao',
                meta: {
                    title: '发票'
                },
                component: resolve => require(['../views/dpzsSwfp/Index.vue'], resolve)
            },

        ]
    }
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
    document.title = to.meta.title || "北京税务局";
    next();
});

export default router
